package com.jwt.config;

import com.jwt.interceptors.JWTInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author ：qs
 * @date ：Created in 2022/3/20
 * @description： 拦截器配置类
 * @modified By：
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {


    /**
     * Add Spring MVC lifecycle interceptors for pre- and post-processing of
     * controller method invocations and resource handler requests.
     * Interceptors can be registered to apply to all requests or be limited
     * to a subset of URL patterns.
     *
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new JWTInterceptor())
                .addPathPatterns("/user/test").excludePathPatterns("/login/**");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
